using Common.Commands;
using Common.Commands.AttachmentCommands;
using Core.Domain.Model;
using Sanelib.DataOperation;
using Sanelib.Dto;

namespace Core.Processors.AttachmentProcessors
{
	public class DeleteAttachmentProcessor : ICommandProcessor<DeleteAttachment>
	{
		private readonly IRepository<Attachment> _attachmentRepository;

		public DeleteAttachmentProcessor(IRepository<Attachment> attachmentRepository)
		{
			_attachmentRepository = attachmentRepository;
		}

		public dynamic Process(DeleteAttachment command)
 		{
			var response = new WebApiResultResponse();

			var attachment = _attachmentRepository.GetById(command.Id);

			_attachmentRepository.Delete(attachment.Id);
			response.IsSuccess = true;

			return response;
		}
	}
}
